package jcommon.chap2_string;

import org.apache.commons.lang.StringUtils;

public class Trim_Strip {
	public static void main(String[] args) {

		System.out.println( "---------- Test trimToNull ----------" );
		trimToNullDemo();

		System.out.println( "---------- Test strip ----------" );
		stripDemo();
	}
	
	private static void trimToNullDemo() {
		String test1 = "\t";
		String test2 = "Test";
		String test3 = null;
		System.out.println( "test1 trimToNull: " + StringUtils.trimToNull( test1 ) );
		System.out.println( "test2 trimToNull: " + StringUtils.trimToNull( test2 ) );
		System.out.println( "test3 trimToNull: " + StringUtils.trimToNull( test3 ) );
	}
	
	//  Specify a set of characters to strip from the beginning and end of a string.
	private static void stripDemo() {
		String original = "-------***---SHAZAM!---***-------";
		String stripped = StringUtils.strip( original, "-*" );
		System.out.println( "Stripped: " + stripped );
	}

}
